Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

i18n-iso-countries

Package Overview
Dependencies
Maintainers
2
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18n-iso-countries

i18n for ISO 3166-1 country codes

  • 7.13.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
530K
decreased by-19.89%
Maintainers
2
Weekly downloads
 
Created

What is i18n-iso-countries?

The i18n-iso-countries npm package provides functionalities for working with ISO 3166-1 country codes. It allows you to get country names in different languages, convert between different country code formats, and validate country codes.

What are i18n-iso-countries's main functionalities?

Get Country Name by Alpha-2 Code

This feature allows you to get the name of a country given its Alpha-2 code. You can specify the language in which you want the country name.

const countries = require('i18n-iso-countries');
countries.registerLocale(require('i18n-iso-countries/langs/en.json'));
const countryName = countries.getName('US', 'en');
console.log(countryName); // Output: United States

Get Alpha-2 Code by Country Name

This feature allows you to get the Alpha-2 code of a country given its name. You can specify the language in which the country name is provided.

const countries = require('i18n-iso-countries');
countries.registerLocale(require('i18n-iso-countries/langs/en.json'));
const countryCode = countries.getAlpha2Code('United States', 'en');
console.log(countryCode); // Output: US

Validate Country Code

This feature allows you to validate whether a given country code is a valid ISO 3166-1 Alpha-2 code.

const countries = require('i18n-iso-countries');
const isValid = countries.isValid('US');
console.log(isValid); // Output: true

Get Country Names in All Languages

This feature allows you to get the names of all countries in a specified language.

const countries = require('i18n-iso-countries');
countries.registerLocale(require('i18n-iso-countries/langs/en.json'));
countries.registerLocale(require('i18n-iso-countries/langs/fr.json'));
const countryNames = countries.getNames('en');
console.log(countryNames); // Output: { 'AF': 'Afghanistan', 'AX': 'Åland Islands', ... }

Other packages similar to i18n-iso-countries

Keywords

FAQs

Package last updated on 07 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc